package com.example.common;

/**
 * 错误码枚举
 * 错误码结构：类型码_模块码_子模块码_场景码_序列号
 * 示例：5_02_03_01_001
 * 类型码说明：
 * 1=系统错误
 * 2=参数错误
 * 5=业务错误
 */
public enum ErrorCode {
    // 系统错误 (1xxxx)
    SYSTEM_ERROR("10000", "系统内部错误"),
    DB_CONNECTION_ERROR("10001", "数据库连接失败"),
    CACHE_ERROR("10002", "缓存服务异常"),
    
    // 参数错误 (2xxxx)
    PARAM_INVALID("20000", "参数校验失败"),
    PARAM_BLANK("20001", "参数不能为空"),
    PARAM_TYPE_ERROR("20002", "参数类型错误"),
    PARAM_FORMAT_ERROR("20003", "参数格式错误"),
    
    // 业务错误 (5xxxx)
    BUSINESS_ERROR("50000", "业务处理失败"),
    USER_NOT_FOUND("50001", "用户不存在"),
    UNAUTHORIZED("50002", "未授权的访问"),
    FORBIDDEN("50003", "禁止访问"),
    RESOURCE_NOT_FOUND("50004", "资源不存在"),

    // 插件模块错误 (5_01_xx_xx)
    PLUGIN_NOT_FOUND("50101", "插件不存在"),
    PLUGIN_STATUS_INVALID("50102", "插件状态无效"),
    PLUGIN_CONFIG_PARSE_ERROR("50103", "插件配置解析失败"),
    PLUGIN_ENABLED_CANNOT_DELETE("50104", "启用状态的插件不能删除"),
    PLUGIN_FILE_DELETE_ERROR("50105", "插件文件删除失败");
    
    private final String code;
    private final String desc;
    
    ErrorCode(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }
    
    public String getCode() {
        return code;
    }
    
    public String getDesc() {
        return desc;
    }
} 